<include file="Public:header" /> <include file="Public:navgation" />
<div class="container-fluid main-content"> 
  <div class="page-title chart-container"> </div>
  <div class="row">
    <div class="col-md-12">
      <div class="widget-container">
        <div class="heading"> <i class="icon-bar-chart"></i>奖票管理
          <if condition="!isMobile()"> <a class="btn btn-default btn pull-right" data-toggle="modal" href="#myModal2" >筛选</a>
            <if condition="getAccessMenu($accessList, 'Intesys', 'Ticket', 'insert')"> <a class="btn btn-primary btn pull-right f-fillwidth" data-toggle="modal" href="#myModal">添加</a> </if>
          </if>
        </div>
        <div class="widget-content padded modal-open">
          <div>总分：<span class="text-primary">{$totalnum}</span></div>
          <if condition="!isMobile()">
                <table id="datatable-editable" class="table table-striped table-bordered dataTable">
                  <thead>
                     <tr>
                      <th>序号</th>
                      <th class="hidden-xs">部门</th>
                      <th>职员</th>
                      <th class="hidden-xs">奖票</th>
                      <th class="hidden-sm hidden-xs">时间</th>
                      <th class="hidden-sm hidden-xs">奖/惩人</th>
                      <th class="hidden-sm hidden-xs">操作人</th>
                      <th style="display:none;">原因</th>
                      <th></th>
                    </tr>
                  </thead>
                  <volist name="list" id="voi" empty="$empty">
                     <tr class="data_list {$key}">
                      <td>{$i}</td>
                      <td class="hidden-xs">{$voi.group_title}</td>
                      <td>{$voi.name}</td>
                      <td>{$voi.number}</td>
                      <td class="hidden-sm hidden-xs">{:date('Y-m-d',$voi['time'])}</td>
                      <td class="hidden-sm hidden-xs">{$voi.rewardername}</td>
                      <td class="hidden-sm hidden-xs">{$voi.givername}</td>
                      <td style="display:none;">{$voi.remark}</td>
                      <td class="text-center actions">
                      	<a class="fancybox table-actions"  href="#fancybox" href="#" ><i class="icon-eye-open"></i></a>
                        <?php $month=strtotime('-1 month');  ?>
                        <egt name="voi['time']" value="$month">
                          <if condition="getAccessMenu($accessList, 'Intesys', 'Ticket', 'update')"> 
                          	<a class="table-actions update f-fillwidth" data-rewarderid="{$voi.rewarder_id}" data-groupid="{$voi.group_id}"  data-ruletype="{$voi.type_id}" href="{:U('update',array('id'=>$voi['id']))}"><i class="icon-pencil"></i></a> 
                          </if>
                          <if condition="getAccessMenu($accessList, 'Intesys', 'Ticket', 'delete')"> 
                          	<a class="delete-row table-actions" href="{:U('delete',array('id'=>$voi['id']))}" row="{$key}"><i class="icon-trash text-danger"></i></a> 
                          </if>
                        </egt>
                      </td>
                    </tr>
                  </volist>
                </table>
                <div class="text-right">{$pages}</div>
            <else/>
            <div class="panel-group tbody" id="accordion">
              <volist name="list" id="vo">
                <div class="panel">
                  <div class="panel-heading">
                    <div class="panel-title"> <a class="accordion-toggle collapsed" data-parent="#accordion" data-toggle="collapse" href="#collapse{$vo.id}">
                      <div class="pull-right text-<?php echo $vo['changenum']>0?'success':'danger' ?>">{$vo.changenum}</div>
                      {$vo.name} </a> </div>
                  </div>
                  <div class="panel-collapse collapse" id="collapse{$vo.id}" style="height: 0;">
                    <div class="panel-body ui-table-split" style="margin-bottom:10px;" >
                      <div><span class="glyphicon glyphicon-flag text-primary" aria-hidden="true"></span>{$vo.group_title}</div>
                      <div><span class="glyphicon glyphicon-time text-primary" aria-hidden="true"></span>{:date('Y-m-d',$vo['time'])}</div>
                      <div><span class="glyphicon glyphicon-user text-primary" aria-hidden="true"></span>{$vo.rewardername}</div>
                      <div><span class="glyphicon glyphicon-user text-primary" aria-hidden="true"></span>{$vo.givername}</div>
                      <div><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span>{$vo.remark}</div>
                    </div>
                  </div>
                </div>
              </volist>
            </div>
          </if>
          <!--modal3 start-->
          <div class="modal fade" id="myModal3" style="display: none;" aria-hidden="true">
            <div class="modal-dialog">
              <div class="modal-content">
                <form method="post" name="form" id="validate-form" class="form-horizontal" novalidate action="__URL__/update">
                  <div class="modal-header">
                    <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                    <h4 class="modal-title">奖励积分</h4>
                  </div>
                  <div class="modal-body">
                    <fieldset>
                      <div class="form-group">
                        <label class="control-label col-sm-2">奖/惩人</label>
                        <div  class="col-sm-5">
                          <select class="form-control groupid" >
                            <option value="">选择部门</option>
                            <foreach name="grouplist" item="vo">
                              <option value="{$vo.id}">{$vo.title}</option>
                            </foreach>
                          </select>
                        </div>
                        <div class="col-sm-5">
                          <select class="form-control memberid" name="rewarder_id">
                            <option value="">选择职员</option>
                          </select>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-sm-2">奖/惩时间</label>
                        <div  class="col-sm-10" style="z-index:1050;">
                          <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                            <input class="form-control" type="text" name="date">
                            <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-sm-2">积分数量</label>
                        <div class="col-sm-10">
                          <input class="form-control" name="number" placeholder="请输入数量" type="number">
                        </div>
                      </div>
                      <div class="form-group"> 
                        <!--<label class="control-label col-sm-2">原因</label>-->
                        <div class="col-sm-12">
                          <html:editor id="editorr" name="remark" type="UEDIT" style="height:300px; width:100%;"></html:editor>
                        </div>
                      </div>
                    </fieldset>
                  </div>
                  <div class="modal-footer">
                    <button class="btn btn-primary" type="submit">修改积分</button>
                    <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                  </div>
                </form>
              </div>
            </div>
          </div>
          <!--modal start-->
          <div class="modal fade" id="myModal" style="display: none;" aria-hidden="true">
            <div class="modal-dialog">
              <div class="modal-content">
                <form method="post" name="form" id="validate-form2" class="form-horizontal" novalidate action="__URL__/insert">
                  <div class="modal-header">
                    <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                    <h4 class="modal-title">奖励奖票</h4>
                  </div>
                  <div class="modal-body">
                    <fieldset>
                      <div class="form-group">
                        <div class="col-sm-10">
                          <div class="input-group">
                            <input readonly class="form-control f-fillname" type="text" placeholder="请选择被奖励人">
                            <input name="memberid" class="form-control" type="hidden" >
                            <span class="input-group-btn">
                            <button class="btn btn-default fancybox" href="#fancybox1" type="button">选择</button>
                            </span> </div>
                        </div>
                      </div>
                      <div class="form-group">
                        <div  class="col-sm-5">
                          <select class="form-control groupid" >
                            <option value="">请选择执行人部门</option>
                            <foreach name="grouplist" item="vo">
                              <option value="{$vo.id}">{$vo.title}</option>
                            </foreach>
                          </select>
                        </div>
                        <div class="col-sm-5">
                          <select class="form-control memberid" name="rewarder_id">
                            <option value="">请选择执行人</option>
                          </select>
                        </div>
                      </div>
                      <div class="form-group">
                        <div  class="col-sm-10" style="z-index:1050;">
                          <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                            <input class="form-control" type="text" name="date" placeholder="请选择执行时间">
                            <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                        </div>
                      </div>
                      <div class="form-group">
                        <div class="col-sm-10">
                          <input class="form-control" value="0" name="number" placeholder="请输入数量" type="number">
                        </div>
                      </div>
                      <div class="form-group"> 
                        <!--<label class="control-label col-sm-2">原因</label>-->
                        <div class="col-sm-12">
                          <html:editor id="editor" name="remark" type="UEDIT" style="height:300px; width:100%;"></html:editor>
                        </div>
                      </div>
                    </fieldset>
                  </div>
                  <div class="modal-footer">
                    <button class="btn btn-primary" type="submit">添加积分</button>
                    <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                  </div>
                </form>
              </div>
            </div>
          </div>
          <!-- modal end and modal2 start-->
          <div class="modal fade" id="myModal2" style="display: none;" aria-hidden="true">
            <div class="modal-dialog">
              <div class="modal-content">
                <form method="get" name="form" class="form-horizontal" novalidate action="__URL__/index">
                  <div class="modal-header">
                    <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                    <h4 class="modal-title">规则筛选</h4>
                  </div>
                  <div class="modal-body">
                    <fieldset>
                      <div class="form-group">
                        <label class="control-label col-sm-2">职员部门</label>
                        <div  class="col-sm-5">
                          <select class="form-control groupid" name="groupid">
                            <option value="">选择部门</option>
                            <foreach name="grouplist" item="vo">
                              <option value="{$vo.id}">{$vo.title}</option>
                            </foreach>
                          </select>
                        </div>
                        <div class="col-sm-5">
                          <select class="form-control memberid" name="member_id">
                            <option value="">选择职员</option>
                          </select>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-sm-2">日期范围</label>
                        <div class="col-sm-5" style="z-index:1050;">
                          <input name="starttime" class="form-control" data-date-autoclose="true" data-date-format="dd-mm-yyyy" id="dpd1" placeholder="开始日期" type="text">
                        </div>
                        <div class="col-sm-5" style="z-index:1050;">
                          <input name="endtime" class="form-control" data-date-autoclose="true" data-date-format="dd-mm-yyyy" id="dpd2" placeholder="结束日期" type="text">
                        </div>
                      </div>
                    </fieldset>
                  </div>
                  <div class="modal-footer">
                    <button class="btn btn-primary" type="submit">筛选</button>
                    <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                  </div>
                </form>
              </div>
            </div>
          </div>
          <!-- modal end and fancybox1 start-->
          <div id="fancybox" style="display: none;">
            <h4 class="text-muted">查看</h4>
            <ul class="no-style">
            </ul>
          </div>
          <!-- fancybox1 end and fancybox1 start-->
          <div id="fancybox1" style="display:none;">

          </div>
          <!-- fancybox1 end --> 
        </div>
      </div>
    </div>
  </div>
</div>
<script>

$(".update").click(function(e) {
    e.preventDefault();
    $("#myModal3 form").attr("action",$(this).attr("href"));
    $("#myModal3 .form-group").find('[name="number"]').val($(this).parents(".data_list").find("td:eq(2)").html());
    $("#myModal3 .form-group").find('[name="date"]').val($(this).parents(".data_list").find("td:eq(4)").html());
    $("#myModal3 .form-group  #editorr #ueditor_0").contents().find("body p").html($(this).parents(".data_list").find("td:eq(3)").html());  
    var groupid=$(this).attr("data-groupid");
    var rewarderid=$(this).attr("data-rewarderid");
	
	//获取和设置奖惩人的部门
	$.getJSON("__GROUP__/Integral_rule/getmembergroup",{'id':rewarderid},function(data){
		if(data.statu!=1){return;}
		groupid=data.groupid
		$(".groupid").find("option[value='"+groupid+"']").attr("selected","selected");
		$.getJSON("__GROUP__/Integral_rule/getmember",{'groupid':groupid},function(data){
			if(data.statu!=1){return;}
			$(".memberid").html('<option value="">请选择</option>');
			$(data.member).each(function(index, element) {
				str=element['id']==rewarderid?"selected='selected'":"";
				$(".memberid").append('<option '+str+' value="'+element.id+'">'+element.name+'</option>');
			});
	   });			
	});
    
    $("#myModal3").modal("show");
    
});

$(".f-changetype").click(function(e) {
    $("#myModal4 [name='id']").val($(this).attr("data-id"));
	$("#myModal4").modal("show");
});

$("#myModal").on("click",'.fancybox[href="#fancybox1"]',function(){
	$.getJSON('__URL__/getMemberGroup',{},function(data){
		if(data.statu==1){
			$("#fancybox1").html(data.result);	
		}	
		console.log(data);
	});
});
//异步获取悬浮框的内容
function ajaxFancybox(url,classname,selectname){
	var url=url||'__GROUP__/Member/getMemberGroup';
	var selectname=selectname||'body';
	var classname=classname||'.f-getMember';
	$(selectname).on("click",classname,function(){
		$.getJSON(url,{},function(data){
			if(data.statu==1){
				$("#fancybox1").html(data.result);	
			}	
			console.log(data);
		});
	});
}
//ajaxFancybox();
</script> 
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> 
<include file="Public:footer" />